/*
** list_apply.c for liblist in /home/guina_b/
** 
** Made by benoit guina
** Login   <guina_b@epitech.net>
** 
** Started on  Fri Jan 01 00:00:00 2010 benoit guina
** Last update Fri Jan 01 00:00:00 2010 benoit guina
*/

#include "list.h"

int	list_apply_r(void *l, int (*f)(void *))
{
  void	*next;
  int	r;

  while (l)
    {
      next = *(void **)l;
      if ((r = f(l)))
	return (r);
      l = next;
    }
  return (0);
}

int	list_apply1_r(void *l, int (*f)(void *, void *p1), void *p1)
{
  void	*next;
  int	r;

  while (l)
    {
      next = *(void **)l;
      if ((r = f(l, p1)))
	return (r);
      l = next;
    }
  return (0);
}

int	list_apply2_r(void *l, int (*f)(void *, void *p1, void *p2),
		      void *p1, void *p2)
{
  void	*next;
  int	r;

  while (l)
    {
      next = *(void **)l;
      if ((r = f(l, p1, p2)))
	return (r);
      l = next;
    }
  return (0);
}
